#include "Element_data.h"
#include "sql_list.h"
//#include "my_head.h"

Elenemt_data student[10] = 
{
    {.id = 1 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张1"},
    {.id = 2 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张2"},
    {.id = 3 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张3"},
    {.id = 4 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张4"},
    {.id = 5 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张5"},
    {.id = 6 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张6"},
    {.id = 7 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张7"},
    {.id = 8 , .age = 18 ,.sco = 89 , .sex = "男" , .name = "张8"},
};

void test(void)
{
    Sql_list * L = Init_Sql_List();
    
    for (int i = 0; i < 8; i++)
    {
        // 扩容操作 如果空间不够 则直接扩容
        if (L->len >= L->max)
        {
            Expand_Sql_List(L , L->max + 1);
            printf("扩容成功\n");
        }
        // 尾插
        tail_insert_tail(L , student[i]);

    }

    

    Expand_Sql_List(L , 30);

    // 插入
    pos_insert_list( L ,  0 , student[7]);
    // 尾删
    int j = find_by_name(L);
    printf("查找成功 姓名 %s\t性别 %s\t年龄 %d\t学号 %d\t成绩 %d\n" , 
    L->data[j].name , 
    L->data[j].sex , 
    L->data[j].age , 
    L->data[j].id , 
    L->data[j].sco);

    Clear_Sql_List(L);
    // 遍历
    printf_Sql_List(L);
    // 销毁
    Destroy_Sql_List(&L);
}

int main(int argc, char const *argv[])
{
    test();
    return 0;
}


